package com.humanmonth.home.component.page.htree
{
	import com.humanmonth.util.effect.GlowUntilClickEffect;
	
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	import mx.core.Application;
	import mx.events.FlexEvent;
	
	public class NodeFormAs extends NodeForm
	{
		public static var whiteBoard:WhiteBoardAs;
		private var node:NodeAs;
		public function NodeFormAs()
		{
			super();
			this.addEventListener(FlexEvent.INITIALIZE,myInit);
		}
		
		private function myInit(event:Event):void{
			this.myCancel.addEventListener(MouseEvent.CLICK,removeMe)
			this.myConfirm.addEventListener(MouseEvent.CLICK,addNode);
			whiteBoard=Application.application.hTree.whiteBoard;
		}
		
		public function setNode(node:NodeAs):void{
			this.node=node;
			this.myName.text=node.myName;
			this.myOrder.text=node.myOrder+"";
		}
		
		
		
		/**
		 * 增加节点到白板中 
		 */
		private function addNode(event:Event):void{
			if(this.node==null){
				var nodet:NodeAs=new NodeAs(whiteBoard.width/2,whiteBoard.height/2,int(this.myOrder.text),this.myName.text);
				new GlowUntilClickEffect(nodet);
			}else{
				this.node.myName=this.myName.text;
				this.node.myOrder=int(this.myOrder.text);
			}
			this.removeMe();
		}
		
	}
}